package com.example.day04.exercise;

import com.example.utils.DateUtil;

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class PrintDate {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入年份：");
        int year=scanner.nextInt();
        System.out.println("输入月份：");
        int month=scanner.nextInt();

        //判断当月一号是星期几

        int week= DateUtil.getDayOfWeek(year,month,1);
        //查看当月有几号
        int maxDays = DateUtil.getMaxDays(year, month);

        //查看当天是周几

        int now= Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

        System.out.println("\t\t"+year+"年"+month+"月");
        System.out.println("一\t二\t三\t四\t五\t六\t日");
        int count=0;
        for(int i=0;i<week-1;i++){
            System.out.printf("\t");
            count++;
        }

        for(int i=1;i<=maxDays;i++){
            System.out.printf(i==now?(i+"*\t"):(i+"\t"));
            if(++count==7){
                System.out.println();
                count=0;
            }
        }
    }
}
